package com.hualu.zks.CommonUtils;
  
import java.awt.Dimension;  
import java.awt.event.ActionEvent;  
import java.awt.event.ActionListener;  
import java.util.concurrent.Executors;  
import java.util.concurrent.ScheduledExecutorService;  
import java.util.concurrent.TimeUnit;  
  
import javax.swing.JButton;  
import javax.swing.JDialog;  
import javax.swing.JFrame;  
import javax.swing.JLabel;  
  
public class LGDialogNoButton {  
    private String message = null;  
    private String message1 = null; 
    private int secends = 0;  
    private JLabel label = new JLabel();  
     private JLabel label1 = new JLabel();  
    private JButton confirm,cancel;   
    private JDialog dialog = null;  
    boolean result = false;  
    public boolean showDialog(JFrame father, String message,String message1, int sec) {  
          
        this.message = message; 
        this.message1 = message1;
        secends = sec;  
        label.setText(message);  
        label.setBounds(80,6,200,20);  
        label1.setText(message1);  
        label1.setBounds(80,30,200,20); 
        ScheduledExecutorService s = Executors.newSingleThreadScheduledExecutor();  
        dialog = new JDialog(father, true);  
        dialog.setTitle("提示: 本窗口将在"+secends+"秒后自动关闭");  
        dialog.setLayout(null);  
        dialog.add(label); 
        dialog.add(label1);
        s.scheduleAtFixedRate(new Runnable() {  
              
            @Override  
            public void run() {  
                // TODO Auto-generated method stub  
                  
                LGDialogNoButton.this.secends--;  
                if(LGDialogNoButton.this.secends == 0) {  
                    LGDialogNoButton.this.dialog.dispose();  
                }else {  
                    dialog.setTitle("提示: 本窗口将在"+secends+"秒后自动关闭");  
                }  
            }  
        }, 1, 1, TimeUnit.SECONDS);  
        dialog.pack();  
        dialog.setSize(new Dimension(350,100));  
        dialog.setLocationRelativeTo(father);  
        dialog.setVisible(true);  
        return result;  
    }  
}  